#{extends '/template/main.html' /}
<script src="/public/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/public/jquery/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="/public/lib/layer/js/layer.js"></script>
<!-- Removing search and results count filter -->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">全部座位</h3>

        <div class="panel-options">
            <a href="/BS0020/admin/seat/add/${seatClassify}">
            <button class="btn btn-success btn-icon">
                <i class="fa-plus-square-o"></i>
                 <span>添加座位</span>
            </button>
            </a>
        </div>
    </div>
    <div class="panel-body">
        <form method="get" id="searchForm" action="/BS0020/admin/seat/index/${seatClassify}/${pageNumber}">
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="seatNo" id="seatNo" class="form-control" style="width:150px" placeholder="座位编号" value="${seatNo}">
            </div>
            <div style="margin-bottom: 20px;width:160px;float: left; margin-right: 10px;">
                <select name="supplierId" class="form-control">
                    <option value="" ${supplierId == null ? 'selected' : ''} >---请选择供应商---</option>
                    #{list supplierList , as:'supplier'}
                    <option value="${supplier?.id}" ${supplierId == supplier?.id ? 'selected' : ''} >${supplier?.name}</option>
                    #{/list}
                </select>
            </div>

        </form>
        <button class="btn btn-turquoise" id="searchBtn">开始检索</button>
        <table class="table table-bordered table-striped" id="example-2">
            <thead>
            <tr>
                <th class="no-sorting">
                    <input type="checkbox" class="cbr">
                </th>
                <th>座位编号</th>
                <th>供应商</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody class="middle-align">
            #{paginate.list items:resultPage , as :'seat'}
            <tr>
                <td>
                    <input type="checkbox" class="cbr">
                </td>
                <td>${seat?.seatNo}</td>
                <td>${seat?.adminSupplier?.name}</td>
                <td>
                    <a href="/BS0020/admin/seat/modify/${seat?.id}/${pageNumber}" class="btn btn-secondary btn-sm btn-icon icon-left">
                        编辑
                    </a>

                    <a href="#" onclick="deletedComfim(${seat?.id});" class="btn btn-danger btn-sm btn-icon icon-left">
                        删除
                    </a>

                    *{<a href="#" onclick="rqCode(${seat?.id});" class="btn btn-info btn-sm btn-icon icon-left">}*
                        *{二维码}*
                    *{</a>}*

                    <a href="/BS0020/admin/seat/seatOrder/${seat?.id}/${seatClassify}/${pageNumber}" class="btn btn-info btn-sm btn-icon icon-left">
                        生成消费订单
                    </a>

                </td>
            </tr>
            #{/paginate.list}

            </tbody>
        </table>
        <div id="layerPage" class="col-xs-12"></div>
    </div>
</div>



<!-- Imported styles on this page -->
<link rel="stylesheet" href="/public/js/datatables/dataTables.bootstrap.css">

<script src="/public/js/datatables/js/jquery.dataTables.min.js"></script>


<!-- Imported scripts on this page -->
<script src="/public/js/datatables/dataTables.bootstrap.js"></script>
<script src="/public/js/datatables/yadcf/jquery.dataTables.yadcf.js"></script>
<script src="/public/js/datatables/tabletools/dataTables.tableTools.min.js"></script>

<script type="text/javascript" src="/public/laypage/laypage.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        // 提示
        var msg = '${flash.get("msg")}';
        if(msg) {
            saveSuccess(msg);
        }

        // 分页
        laypage({
            cont: $('#layerPage'), //容器。值支持id名、原生dom对象，jquery对象,
            pages: '${resultPage?.pageCount}', //总页数
            skin: 'yahei',
            curr:'${pageNumber}',
            jump: function(e, first){ //触发分页后的回调
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    $('#pageNumber').val(e.curr);
                    $("#searchForm").attr("action", "/BS0020/admin/seat/index/${seatClassify}/"+e.curr);
                    $('#searchForm').submit();
                }
            }
        });
        $(document).on("click", "#searchBtn", function(){
            $("#searchForm").attr("action", "/BS0020/admin/seat/index/${seatClassify}/1");
            $('#searchForm').submit();
        })
    });


    //点击确认删除 之后执行的方法
    function sureDeleted() {
        //获取删除的id
        var id = $('#deleteId').val();
        document.location.href='/BS0020/admin/seat/delete/'+id+'/${pageNumber}';
    }

    function rqCode(id) {
        var url = '${weixin_url}' + "/" + id;
        layer.open({
            title:"付款",
            type: 1,
            area: ['600px', '500px'],
            fixed: true,
            maxmin: false,
            content: '<div id="wechat-img"> </div>'
        });
        $('#wechat-img').qrcode({width:250,height:250,correctLevel:0,text: url}).show();
    }

    //创建订单
    function createForSeat(id) {

    }

</script>


